<?php
require_once "default/models/Prueba_Abm.php";
Class Default_Index_Controller extends Gi_Controller_Action {
  public $abm = null;
  
  public function pre_dispatch () {
    $this->abm = new Prueba_Abm();
    $this->view->assign("root_url",$this->request->get_base_url());
  }
  public function index_action () {
    $this->view->render("frame.html");
  }
  public function  browse_action() {
  /*  
Propiedad             Tipo        Descripcion
first                 integer     Numero de la primera pagina (i.e., 1) 
first_item_number     integer     numero del primer item de la pagina
current               integer     Numero de pagina actual
last                  integer     Numero de la ultima pagina
last_item_number      integer     Numero del ultimo item de la pagina
next                  integer     Numero de la proxima pagina
page_count            integer     Numero de paginas totales
previous              integer     Numero de la pagina anterior
total_item_count      integer     Numero total de items
*/
  
    $page = $this->request->get[page];
    $data = $this->abm->do_browse($page);
    $this->view->assign("abm_data",$data);
    $this->view->assign("center_tpl","abm_browse.html");
    $this->view->render("frame.html");
  }
  
  public function view_action () {
    $id = $this->request->get[id];
    $data = $this->abm->do_view($id);
    $this->view->assign("abm_data",$data);
    $this->view->assign("center_tpl","abm_view.html");
    $this->view->render("frame.html");
  }
  
  public function new_action () {
    $meta = $this->abm->get_metadata();
    $this->view->assign("meta",$meta);
    if ($this->request->post) {
      $data = $this->request->post;
      $id = $this->abm->do_new($data);
      $this->redirect("index/view?id=$id");
    }
    $this->view->assign("center_tpl","abm_new.html");
    $this->view->render("frame.html");
  }
}